package com.base.txl.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;

import com.fan.txl.BuildConfig;
import com.fan.txl.ui.routers.ComponentRouters;
import com.github.mzule.activityrouter.router.Routers;

/**
 * Created by os on 2017/1/5.
 */

public class ComponentUtils {

    public static final String dataFlag="data";

    public static void start(Context context, Class<? extends Activity> activity,Parcelable data) {

        Intent starter = new Intent(context, activity);
        if (data!=null){
            starter.putExtra(dataFlag,data);
        }
        context.startActivity(starter);
    }

    public static void start(Context context, Class<? extends Activity> activity) {
        start(context,activity,null);
    }

    public static void start(Context context,String router) {
        if (router.startsWith(ComponentRouters.http)){
            Routers.open(context,router);
        }else if (!router.startsWith(ComponentRouters.scheme)){
            Routers.open(context,ComponentRouters.scheme+router);
        }
    }

    public static void start(Context context,Parcelable data) {
        /*ActivityRoute activityRoute = (ActivityRoute) Router.getRoute(router);
        activityRoute
                .withParams(dataFlag, data)
                .open();*/
    }



}
